<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style>
#div1 {width:200px; height:200px; background:red;}
</style>
<script>
function setStyle(name, value)
{
	var oDiv=document.getElementById('div1');
	
	oDiv.style[name]=value;
}

/*
function toWidth()
{
	var oDiv=document.getElementById('div1');
	
	oDiv.style.width='400px';
}

function toHeight()
{
	var oDiv=document.getElementById('div1');
	
	oDiv.style.height='400px';
}

function toGreen()
{
	var oDiv=document.getElementById('div1');
	
	oDiv.style.background='green';
}*/
</script>
</head>

<body>
<input type="button" value="变宽" onclick="setStyle('width', '400px')" />
<input type="button" value="变高" onclick="setStyle('height', '400px')" />
<input type="button" value="变绿" onclick="setStyle('background', 'green')" />
<div id="div1">
</div>
</body>
</html>
